package com.lsu.component.practice;

import java.util.ArrayList;
import java.util.List;

/**
 * 根节点的实现类
 *
 * @Author wang suo
 * @Date 2020/12/22 0022 11:03
 * @Version 1.0
 */
public class Root implements IRoot {
    /**
     * 保存根节点下的所有树枝节点和树叶节点
     */
    private List<Object> subordinateList = new ArrayList<>();

    /**
     * 根节点的名称
     */
    private String name = "";

    /**
     * 根节点的职位
     */
    private String position = "";

    /**
     * 根节点的薪水
     */
    private int salary = 0;

    public Root(String name, String position, int salary) {
        this.name = name;
        this.position = position;
        this.salary = salary;
    }

    @Override
    public String getInfo() {
        String info = "";
        info = "名称: " + this.name;
        info = info + "\t职位: " + this.position;
        info = info + "\t薪水: " + this.salary;
        return info;
    }

    /**
     * 增加树叶节点
     *
     * @param iBranch 有分支的节点
     */
    @Override
    public void add(IBranch iBranch) {
        subordinateList.add(iBranch);
    }

    /**
     * 增加叶子节点-直属于总经理的-比如秘书
     *
     * @param iLeaf 叶子节点
     */
    @Override
    public void add(ILeaf iLeaf) {
        subordinateList.add(iLeaf);
    }

    @Override
    public List getSubordinateInfo() {
        return this.subordinateList;
    }
}
